package tests;

import static org.junit.Assert.*;

import java.util.ArrayList;

import org.junit.Test;

import base.Ship;

import pathfinding.GridCell;
import pathfinding.GridGeometry;

public class GridGeometryTest {

	@Test
	public void testGetCenter() {
		fail("Not yet implemented");
	}

	@Test
	public void testGetCell() {
		GridCell c;
		double full = GridGeometry.gridSize;
		double small = 0.1 * full;
		
		c = GridGeometry.getCell(new Ship(0,0,0,0,0));
		assertTrue(c.equals(new GridCell(0,0)));
		
		c = GridGeometry.getCell(new Ship(0,0,small,small,0));
		assertTrue(c.equals(new GridCell(0,0)));
		
		c = GridGeometry.getCell(new Ship(0,0,-small,small,0));
		assertTrue(c.equals(new GridCell(-1,0)));
		
		c = GridGeometry.getCell(new Ship(0,0,-small,-small,0));
		assertTrue(c.equals(new GridCell(-1,-1)));
		
		c = GridGeometry.getCell(new Ship(0,0,full, full,0));
		assertTrue(c.equals(new GridCell(1,1)));
		
		c = GridGeometry.getCell(new Ship(0,0,full + small, full + small,0));
		assertTrue(c.equals(new GridCell(1,1)));
		
		c = GridGeometry.getCell(new Ship(0,0,full - small, full - small,0));
		assertTrue(c.equals(new GridCell(0,0)));
		
		c = GridGeometry.getCell(new Ship(0,0,-full - small, full - small,0));
		assertTrue(c.equals(new GridCell(-2,0)));
		
		c = GridGeometry.getCell(new Ship(0,0,-full + small, full - small,0));
		assertTrue(c.equals(new GridCell(-1,0)));
		
		c = GridGeometry.getCell(new Ship(0,0,-full + small, -full - small,0));
		assertTrue(c.equals(new GridCell(-1,-2)));
	}

	@Test
	public void testGetCells() {
		ArrayList<GridCell> result;
		Ship s = new Ship(0,0,0,0,0);
		
		s.setY(0);
		s.setX(0);
		result = GridGeometry.getCells(s);
		assertTrue(result.size() == 2);
		
		s.setHeading(90);
		s.setY(GridGeometry.gridSize);
		s.setX(GridGeometry.gridSize);
		result = GridGeometry.getCells(s);
		assertTrue(result.size() == 6);
		
		
		s.setHeading(45);
		result = GridGeometry.getCells(s);
		assertTrue(result.size() == 4);
	}

	@Test
	public void testGetRectangle() {
		fail("Not yet implemented");
	}

	@Test
	public void testEqualCells() {
		fail("Not yet implemented");
	}
}
